<html>
<head>
<link rel='stylesheet' href='../../../js/sh/SyntaxHighlighter.css' type='text/css' />
<script src='../../../js/sh/shCore.js'></script>
<script src='../../../js/sh/shBrushJava.js'></script>
<style>
* {
font-family:Courier New,monospace;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  font-size: 11px;
}
.dp-highlighter {
  white-space: nowrap;
  overflow: visible;
  width: 600px;
  font-size: 11px;
  font-family:Courier New,monospace;
}
</style>
</head>
<body>
<textarea name='code' class='java:nogutter' rows='15' cols='120'>
/*
 * SmartGWT (GWT for SmartClient)
 * Copyright 2008 and beyond, Isomorphic Software, Inc.
 *
 * SmartGWT is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.  SmartGWT is also
 * available under typical commercial license terms - see
 * http://smartclient.com/license
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 */

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DragAppearance;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VStack;

import java.util.HashMap;
import java.util.Map;

public class DragMoveImageSample implements EntryPoint {

    public void onModuleLoad() {
        HStack hStack = new HStack(10);
        hStack.setLayoutMargin(10);
        hStack.setLeft(120);
        hStack.setShowEdges(true);
        hStack.setEdgeImage("edges/blue/6.png");
        hStack.setCanAcceptDrop(true);
        hStack.setAnimateMembers(true);
        hStack.setShowDragPlaceHolder(true);
        hStack.setBorder("1px solid #4040ff");
        hStack.addMember(new DragPiece("cube_blue.png"));
        hStack.addMember(new DragPiece("cube_green.png"));
        hStack.addMember(new DragPiece("cube_yellow.png"));
        

        VStack vStack = new VStack(10);
        vStack.setLayoutMargin(10);
        vStack.setShowEdges(true);
        vStack.setEdgeImage("edges/green/6.png");
        vStack.setCanAcceptDrop(true);
        vStack.setAnimateMembers(true);
        vStack.setDropLineThickness(4);
        Canvas dropLineProp = new Canvas();
        dropLineProp.setBackgroundColor("#40c040");
        vStack.setDropLineProperties(dropLineProp);
        vStack.addMember(new DragPiece("cube_blue.png"));
        vStack.addMember(new DragPiece("cube_green.png"));
        vStack.addMember(new DragPiece("cube_yellow.png"));
        
        Canvas main = new Canvas();
        main.addChild(hStack);
        main.addChild(vStack);
        
        
        main.draw();
    }

    
    private class DragPiece extends Img {
    	public DragPiece() {
    		setWidth(48);
    		setHeight(48);
    		setLayoutAlign(Alignment.CENTER);
    		setCanDragReposition(true);
    		setCanDrop(true);
    		setDragAppearance(DragAppearance.TARGET);
    		setAppImgDir("pieces/48/");
    	}
    	
    	public DragPiece(String src) {
    		this();
    		setSrc(src);
    	}
    }

}
</textarea>
<script class='javascript'>
dp.SyntaxHighlighter.HighlightAll("code");
</script>
</body>
</html>
